{include file="common/meta" /}
{include file="common/script" /}
<link href="__CDN__/assets/libs/fastadmin-citypicker/dist/css/city-picker.css" rel="stylesheet" />
<div class="container-fluid margin padding">
	<div class="row">
		<!-- 订单信息 -->
		<div class="col-md-10 col-md-offset-1 col-sm-12">
			<form class="form-horizontal" method="POST" name="myForm" id="myForm" action="">

				<input type="hidden" name="address_id" value="{$vo.id}">
			    <div class="form-group hide">
			        <label for="country" class="col-sm-2 control-label">{:__('country')}</label>
			        <div class="col-sm-10">
			            <input type="text" readonly class="form-control" id="country" value="{$vo.country}" name="country" placeholder="{:__('country')}">
			        </div>
			    </div>
			    <div class="form-group">
			        <label for="country" class="col-sm-2 control-label">{:__('province / city / xian')}</label>
			        <div class="col-sm-10">
			            <input type="text" data-responsive="true" data-toggle="city-picker" class="form-control" id="region" value="{$vo.region}" name="region" placeholder="{:__('province / Region')}">
			        </div>
			    </div>
			    <div class="form-group">
			        <label for="city" class="col-sm-2 control-label">{:__('set default')}</label>
			        <div class="col-sm-10 padding-top">
						<!-- radio -->

						<div class="form-group" style="padding-left: 15px;">
							<label>
								<input type="radio" name="status" {if condition="$vo.status eq 1"} checked {/if} value="1" class="flat-red" />
								{:__('yes')}
							</label>
							<label>
								<input type="radio" name="status" {if condition="$vo.status eq 0"} checked {/if} class="flat-red" value="0" />
								{:__('no')}
							</label>
						</div>
			        </div>
			    </div>
			    <div class="form-group">
			        <label for="zip" class="col-sm-2 control-label">{:__('zip code')}</label>
			        <div class="col-sm-10">
			            <input type="text" class="form-control" value="{$vo.zip}" id="zip" name="zip" placeholder="{:__('zip code')}">
			        </div>
			    </div>
			    <div class="form-group">
			        <label for="mobile" class="col-sm-2 control-label">{:__('mobile')}</label>
			        <div class="col-sm-10">
			            <input type="text" class="form-control" value="{$vo.mobile}" id="mobile" name="mobile" placeholder="{:__('mobile')}">
			        </div>
			    </div>
			    <div class="form-group">
			        <label for="truename" class="col-xs-2 control-label">{:__('consignee')}</label>
			        <div class="col-xs-10">
			            <input type="text" class="form-control" value="{$vo.truename}" id="truename" name="truename" placeholder="{:__('姓名')}">
			        </div>
			    </div>

			    <div class="form-group">
			        <label for="firstname" class="col-sm-2 control-label">{:__('detail address')}</label>
			        <div class="col-sm-10">
			            <textarea name="address" id="address" value="{$vo.address}" class="form-control" rows="5">{$vo.address}</textarea>
			        </div>
			    </div>
			    <div class="form-group">
					<div class="col-sm-2 col-sm-offset-5 col-xs-12">
				    	<button class="btn btn-info btn-block" id="save" type="button">{:__('save')}</button>
				    </div>
				</div>
			</form>

		</div>
	</div>
</div>
{include file="common/script"}
<script src="__CDN__/assets/libs/fastadmin-citypicker/dist/js/city-picker.data.min.js"></script>
<script src="__CDN__/assets/libs/fastadmin-citypicker/dist/js/city-picker.min.js"></script>
<script>
	$(document).ready(function() {
		var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
		$("#save").on('click', function() {

			var url = "{:addon_url('leescore/address/edit')}";
			var data = $("#myForm").serialize();
			$.ajax({
				url: url,
				type: 'POST',
				dataType: 'json',
				data: data,

				success: function(json)
				{
					if(json.status == true)
					{
						parent.location.reload();
						//关闭父级弹窗
					    parent.layer.close(index);
					}else{
						layer.alert(json.msg, {
							icon: 2,
							skin: 'layer-ext-moon' 
						});
					}
				}
			});
			
		});
	});
</script>
